package com.aopcinemas.visitor;

import jade.core.Agent;
import jade.domain.DFService;
import jade.domain.FIPAException;
import jade.domain.FIPAAgentManagement.DFAgentDescription;
import jade.domain.FIPAAgentManagement.ServiceDescription;

public class VisitorUtils {

    public static void registerCampaign(Agent agent) {
        DFAgentDescription dfd = new DFAgentDescription();
        dfd.setName(agent.getAID());
        ServiceDescription sd = new ServiceDescription();
        sd.setType(VisitorConstants.VISITOR_COMPAIGN);
        sd.setName(VisitorConstants.VISITOR_COMPAIGN);// XXX should be here some
        dfd.addServices(sd);
        try {
            DFService.register(agent, dfd);
        } catch (FIPAException e) {
            throw new RuntimeException("Can't register campaign!");
        }
    }

    public static void unregisterCampaign(Agent agent) {
        try {
            DFService.deregister(agent);
        } catch (FIPAException e) {
            throw new RuntimeException("Can't unregister campaign!");
        }
    }

}
